package com.eiletxie.springcloud.controller;

import com.eiletxie.springcloud.entities.CommonResult;
import com.eiletxie.springcloud.entities.Payment;
import com.eiletxie.springcloud.entities.User;
import com.eiletxie.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpRequest;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author EiletXie
 * @Since 2020/3/11 13:49
 */
@RestController
@Slf4j
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping(value="/consumer/payment/get/{id}")
    public String getPaymentById(@PathVariable("id")  Long id) {
        return  paymentFeignService.getPaymentById(id);
    }

    @GetMapping(value = "/consumer/payment/feign/timeout/{id}")
    public String paymentFeignTimeout(@PathVariable("id")  Long id) {
        //openfeign-ribbon 客户端默认等待1S
        return  paymentFeignService.paymentFeignTimeout(id);
    }
    @GetMapping(value = "/consumer/payment/circuit/{id}")
    public String circuit(@PathVariable("id")  Integer id) {
        //openfeign-ribbon 客户端默认等待1S
        System.out.println("id"+id);
        return  paymentFeignService.circuit(id);
    }

    @PostMapping(value = "/payment/feign/postResonse")
    public String postResonse(@RequestBody String test) {
        //openfeign-ribbon 客户端默认等待1S
        log.info("进入对应的客户端：此时的数据test="+test);
        return  paymentFeignService.postResonse(test);
    }

    @PostMapping(value = "/payment/feign/post1")
    public String post1(@RequestBody User user, HttpServletRequest requestHandler) {
        //openfeign-ribbon 客户端默认等待1S
        System.out.println(requestHandler);
        return  paymentFeignService.post1(user);
    }
}
